package exception;

import be.kuleuven.cs.som.annotate.Basic;
import roborally.supporting.Unit;

/**
 * An exception class representing an exception by converting one unit to another.
 * 
 * @author Molderez Tom, 2de bach Ingenieurswetenschappen Computerwetenschappen-Elektrotechniek and Reniers Jorn, 2de bach Ingenieurswetenschappen Werktuigkunde-Computerwetenschappen
 * @version 1.0
 */
public class IllegalConvertionException extends RuntimeException {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * Creates a new IllegalConvertionException.
	 * 
	 * @param message The message of this exception
	 * @param to The unit to convert to.
	 * @param from The unit to convert from.
	 * @pre To may not be null.
	 * 		| to != null
	 * @pre From may not be null.
	 * 		| from != null
	 */
	public IllegalConvertionException(String message, Unit to, Unit from) {
		super(message);
		this.to = to;
		this.from = from;
	}
	
	/**
	 * Returns the message of this IllegalConvertionException.
	 */
	@Override @Basic
	public String getMessage() {
		return super.getMessage() + "\nUnit converted to: " + to.toString() + ", Unit converted from: " + from.toString();
	}
	
	private final Unit to;
	private final Unit from;

}
